<html>
<head><meta charset="utf-8"><title>patch-in-config · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html">patch-in-config</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="243184692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243184692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243184692">(Jun 18 2021 at 16:46)</a>:</h4>
<p>I'm starting to take advantage of <a href="https://github.com/rust-lang/cargo/issues/9269"><code>patch-in-config</code></a>, and it's looking _very_ promising so far. The biggest pain-point is that the build system I'm working with has to inject patches for _all_ the dependencies it manages, even if the actual Rust crate only declares a dependency on a subset of them. This, in turn leads to unfortunate warnings of the kind:</p>
<div class="codehilite"><pre><span></span><code>warning: Patch `hello_world v0.1.0 (/.../hello_world-0.1.0)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
</code></pre></div>
<p>That warning is _normally_ very much desirable, but in this _particular_ case it isn't. So, I wanted to take the temperature on adding a flag along the lines of <code>allow-unused-patch = ["hello_world"]</code> in <code>.cargo/config.toml</code> to suppress the warning for specific dependencies?</p>



<a name="243277592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243277592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243277592">(Jun 20 2021 at 00:44)</a>:</h4>
<p>It's not feasible to quickly detect the dependency tree and just feed in patches for those?</p>



<a name="243311206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243311206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243311206">(Jun 20 2021 at 16:56)</a>:</h4>
<p>It's not impossible, but somewhat inconvenient. The bigger concern is that it would require that users re-run the "big" build system if they added a dependency line to their Cargo.toml so that the patch would get added. If all the patches were there already, they'd be able to stick with just the standard Rust tools.</p>



<a name="243339959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243339959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243339959">(Jun 21 2021 at 04:56)</a>:</h4>
<p>Ah, I see.</p>



<a name="243339966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243339966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243339966">(Jun 21 2021 at 04:57)</a>:</h4>
<p>(What's the "big" build system here?)</p>



<a name="243339986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243339986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243339986">(Jun 21 2021 at 04:57)</a>:</h4>
<p>In any case, I don't see any <em>fundamental</em> reason we couldn't have an option to disable the warning for an unused patch.</p>



<a name="243340032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243340032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243340032">(Jun 21 2021 at 04:58)</a>:</h4>
<p>I think we still need to catch cases where you'd expect it to be used and it isn't, such as a version mismatch. But I imagine that's less of a concern if everything is vendored.</p>



<a name="243405636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243405636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243405636">(Jun 21 2021 at 16:10)</a>:</h4>
<p>It's Amazon's internal build system called Brazil :)</p>



<a name="243405770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243405770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243405770">(Jun 21 2021 at 16:11)</a>:</h4>
<p>I almost wonder if this is specifically the case of patches _in configs_. I think it's maybe reasonable to say that for patches in <code>Cargo.toml</code> — all of them should be used, and that only in the case of a <code>.cargo/config</code> patch might the warning be allowable. What do you think?</p>



<a name="243405901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243405901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243405901">(Jun 21 2021 at 16:12)</a>:</h4>
<p>Though actually, thinking about it some more, I think it's likely okay in this case to require re-running the "big" build system if a dependency is added. There are some other things we'll want to do in that case too, so I can just add "update patches" to that. I'll go that route for now and see how far it gets me <span aria-label="+1" class="emoji emoji-1f44d" role="img" title="+1">:+1:</span></p>



<a name="243412430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243412430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> XAMPPRocky <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243412430">(Jun 21 2021 at 17:05)</a>:</h4>
<p><span class="user-mention" data-user-id="120054">@Jon Gjengset</span> I can’t decide if that’s a really clever or ominous name for your build system. 🙂</p>



<a name="243427055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243427055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243427055">(Jun 21 2021 at 18:56)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120054">Jon Gjengset</span> <a href="#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243405770">said</a>:</p>
<blockquote>
<p>I almost wonder if this is specifically the case of patches _in configs_. I think it's maybe reasonable to say that for patches in <code>Cargo.toml</code> — all of them should be used, and that only in the case of a <code>.cargo/config</code> patch might the warning be allowable. What do you think?</p>
</blockquote>
<p>Yes, I think that's the correct approach. I'd also say that you should still detect version mismatches, and just allow for "there's no dependency on that crate at all".</p>



<a name="243427170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/patch-in-config/near/243427170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/patch-in-config.html#243427170">(Jun 21 2021 at 18:56)</a>:</h4>
<p>I don't see any problem with having an opt-out for the warning, since it isn't fundamentally fatal. It would just change patches from "patch this dependency" to "if I have this as a dependency, patch it".</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>